
# params
CC=gcc
CXX=g++
EXTRADEFS=-DLINUX_OS -DGIMI_NO_DATATYPE_INCLUDES $(CE) -I ../
WFLAGSC=-Wall -Wunused -Wshadow
WFLAGSCPP=-Wall -Wunused -Wshadow -Weffc++
WFLAGSDCPP=
LD=g++
LDFLAGS=
LIBS=-lglut -lrt -lpthread

# Construct final lists of CPP and C objects
OBJSC=$(SRCSC:.c=.o)
OBJSCPP=$(SRCSCPP:.cpp=.opp)
MACIOBJSCPP=$(MACISRCSCPP:.cpp=.opp)

# Define COMPILE and LINK commands
COMPILEC=$(CC) $(CFLAGS) -c
COMPILECPP=$(CXX) $(CPPFLAGS) -c -I ../
COMPILEDCPP=$(CXX) $(DCPPFLAGS) -c -I ../
LINK=$(LD) $(LDFLAGS) $(LIBS) 

.PHONY: all

# Define targets
TARGETS=SandViewer

# All rule compiles all per default
all:	$(TARGETS)

###############################################
###############################################
SANDVIEWER_OBJECTS=$(OBJSC) $(OBJSCPP) \
			SandViewer.opp \
			Sand.opp 

SandViewer: $(SANDVIEWER_OBJECTS)
	@$(LINK) -o $@ $^
	@echo "      [LD] $@"
##############################################

###############################################
###############################################
.PHONY: clean maci-clean maciclean real-clean realclean
local-clean clean:
	@rm -f *.o *.opp *.dopp $(TARGETS)
	@echo "     [LOCAL-CLEAN]"

maci-clean maciclean: clean
	rm -f $(MACIOBJSCPP)
	@echo "     [MACI-CLEAN]"

real-clean realclean: maciclean
	rm -f $(OBJSC) $(OBJSCPP) \
	$(DUMMY_DUMMY_OBJECTS) 
	@echo "     [REAL-CLEAN]"

########### Compile rules ####################
# Compile rule for all .o (.c) file
%.o:	%.c
	@$(COMPILEC) -o $@ $<
	@echo "      [CC] $<"

# Compile rule for all .opp (.cpp) files
%.opp:	%.cpp
	@$(COMPILECPP) -o $@ $<
	@echo "      [CXX] $<"

# Compile rule for all .dopp (dirty .cpp) files
%.dopp:	%.cpp
	@$(COMPILEDCPP) -o $@ $<
	@echo "      [DIRTY-CXX] $<"

##############################################
